package org.ruoyi.common.dhuman.ppt;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

/**
 * 图片预处理工具类
 */
class ImagePreprocessor {

	/**
	 * 图片预处理，提高OCR识别准确率
	 */
	public static BufferedImage preprocessImage(BufferedImage original) {
		BufferedImage processed = new BufferedImage(
			original.getWidth(),
			original.getHeight(),
			BufferedImage.TYPE_BYTE_BINARY
		);

		Graphics2D g = processed.createGraphics();
		g.drawImage(original, 0, 0, null);
		g.dispose();

		// 可以添加更多的图像处理操作，如：
		// - 二值化
		// - 降噪
		// - 对比度增强
		// - 尺寸调整等

		return processed;
	}

	/**
	 * 调整图片尺寸
	 */
	public static BufferedImage resizeImage(BufferedImage original, int targetWidth, int targetHeight) {
		BufferedImage resized = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
		Graphics2D g = resized.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		g.drawImage(original, 0, 0, targetWidth, targetHeight, null);
		g.dispose();
		return resized;
	}
}
